<?php
/**
 * @file changePassword.php
 * @author LD <2009-10-30 10:01:25>
 * @package kbao
 * @desc 
 *   修改K币交易系统安全密码
 */
if(!defined('ACCOUNT_INIT'))
	exit('Access Denied!');

/* 定义全局变量 */
global $gLD;

/**
 * 是否新增/重设密码
 */
if ( $_SESSION['account_dkb']['dkb_pass'] != 1 ){
	$gLD['pswd_type'] = '*NEWSET';
}

$action = check($_POST['action']);
$kmpswd = check($_POST['kmpswd']); //K秀登陆密码
$pswd = check($_POST['pswd']); //新安全密码
$pswd2 = check($_POST['pswd2']); //新安全密码
$oldpswd = check($_POST['oldpswd']); //旧安全密码
$user_id = check($_POST['user_id']);

if ($action == 'chgpswd' and !empty($pswd) and !empty($kmpswd) ){
	if ( strlen($pswd) != 8 ){
		$gLD['msg'] = "密码必须为8位英文或数字字符！";
	}elseif ($pswd != $pswd2){
		$gLD['msg'] = "两次输入的密码不一致！";
	}else {
		$re = Appleseed::chgBurzaPasswd($user_id, $kmpswd, $pswd, $oldpswd);
		if ($re == '1'){  //密码修改成功...,重新登陆
			echo "<script type='text/javascript'>alert('您的账户安全密码修改成功，请重新登录.');"
			  ."window.location='?black%20hole={$gLD['BlackHole']}&sessionKey={$gLD['sessionKey']}&uin={$gLD['user_id']}&module=login';</script>";
			//header("LOCATION:entry.php?black%20hole={$gLD['BlackHole']}&uin={$gLD['user_id']}&module=login");
			exit;
		}elseif ($re == '-1'){
			$gLD['msg'] = "登陆密码错误！";
		}elseif ($re == '-2'){
			$gLD['msg'] = "原安全密码错误！";
		}else{
			echo "网络延时，请稍后再试！";
		}//END 错误处理
	}
}
	//载入视图模版文件
require_once 'view/VchangePassword.php';
?>